//----------------------------------------------------------------------------------------
// @Project Includes
#include "includes.h"

//----------------------------------------------------------------------------------------
// @Local Macro Define in the module

//----------------------------------------------------------------------------------------
// @Local Type defines in the module

//----------------------------------------------------------------------------------------
// @Global Variables define in the module
stc_ota_updata_t gstcOtaUpdata = {0};
stc_ota_updatainfo_t gstcOtaUpdataInfo = {0};

//----------------------------------------------------------------------------------------
// @Prototypes of functions in the module

//========================================================================================
/*
 * @Functions:   bool drv_upgrade_check(void)
 * @Description: 升级检测
 * @Parameters:  NONE
 * @Return:      true:需要升级;false:不需要升级;
 */
bool drv_upgrade_check(void)
{
#if 1
    uint8_t readBuf[UPDATE_TAG_SIZE] = {0};
    drv_flash_read(readBuf, OTA_CONFIG_ADDR, UPDATE_TAG_SIZE);
	
    gstcOtaUpdata.flag = (((uint16_t)readBuf[0] << 8)|((uint16_t)readBuf[1]));
    gstcOtaUpdata.ecu =  readBuf[2];
    gstcOtaUpdata.u16fwVer = (((uint16_t)readBuf[3] << 8)|((uint16_t)readBuf[4]));
    gstcOtaUpdata.u32fwSize = (((uint32_t)readBuf[5]<<24) | ((uint32_t)readBuf[6] << 16) | ((uint32_t)readBuf[7] << 8) | ((uint32_t)readBuf[8]));
    gstcOtaUpdata.u16fwCrc16 = (((uint16_t)readBuf[9] << 8)|((uint16_t)readBuf[10]));

#else
	BswDrv_Flash_Read((uint8_t*)&gstcOtaUpdata, OTA_CONFIG_ADDR, UPDATE_TAG_SIZE);
#endif

    if(gstcOtaUpdata.flag == 0x5AA5)
    {
        return true;
    }
    else
    {
        return false;
    }

}


// =======================================================================================
// End of file.
// =======================================================================================
